/*
 * GPUC
 * 
 * Copyright © 2008 Attila T. Áfra <attila.afra@gmail.com>
 * 
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this program. If
 * not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "Common.hpp"
#include "Uncopyable.hpp"
#include "Exception.hpp"

/*------------------------------------------------------------------------------------------------*/

namespace GPUC
{
    class Stream : Uncopyable
    {   
    public:
        static bool isFormatSupported(Type elementType);
        static int getMaxDimension();

        Stream(int width, int height, Type type);
        ~Stream();

        GPUC_Stream getObject() const;
        int getWidth() const;
        int getHeight() const;
        Type getElementType() const;
        size_t getSize() const;

    private:
        GPUC_Stream stream;
    };
}

/*------------------------------------------------------------------------------------------------*/

bool GPUC::Stream::isFormatSupported(GPUC::Type elementType)
{
    const bool result = GPUC_Stream_isFormatSupported(static_cast<GPUC_Type>(elementType));
    Internal::checkError();
    return result;
}

/*------------------------------------------------------------------------------------------------*/

int GPUC::Stream::getMaxDimension()
{
    const int result = GPUC_Stream_getMaxDimension();
    Internal::checkError();
    return result;
}

/*------------------------------------------------------------------------------------------------*/

GPUC::Stream::Stream(int width, int height, Type type)
{
    stream = GPUC_Stream_create(width, height, static_cast<GPUC_Type>(type));
    Internal::checkError();
}

/*------------------------------------------------------------------------------------------------*/

GPUC::Stream::~Stream()
{
    GPUC_Stream_destroy(stream);
}

/*------------------------------------------------------------------------------------------------*/

GPUC_Stream GPUC::Stream::getObject() const
{
    return stream;
}

/*------------------------------------------------------------------------------------------------*/

int GPUC::Stream::getWidth() const
{
    return GPUC_Stream_getWidth(stream);
}

/*------------------------------------------------------------------------------------------------*/

int GPUC::Stream::getHeight() const
{
    return GPUC_Stream_getHeight(stream);
}

/*------------------------------------------------------------------------------------------------*/

GPUC::Type GPUC::Stream::getElementType() const
{
    return static_cast<Type>(GPUC_Stream_getElementType(stream));
}

/*------------------------------------------------------------------------------------------------*/

size_t GPUC::Stream::getSize() const
{
    return GPUC_Stream_getSize(stream);
}

/*------------------------------------------------------------------------------------------------*/
